from tkinter import *

win = Tk()
win.title("C语言中文网")
win.geometry('400x300')
win.iconbitmap('qianduan\logo.ico')

text = Text(win,width=50,height=20,undo=True,autoseparators=False)
text.grid()

text.insert(INSERT,"YOLO,一个有温度的网站")

def backout():
  text.edit_undo()
def regain():
  text.edit_redo()

Button(win,text='撤销',command=backout).grid(row=3,column=0,sticky='w',padx=10,pady=5)
Button(win,text='恢复',command=regain).grid(row=3,column=0,sticky='e',padx=10,pady=5)
win.mainloop()